package com.treasure.service.common.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.commission.service.CommissionService;
import com.treasure.service.domain.TImageConfig;
import com.treasure.service.domain.TImageConfigExample;
import com.treasure.service.domain.TUserInfo;
import com.treasure.service.mapper.TImageConfigMapper;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;

/** 
* @ClassName    : CommonController 
* @author       : panxingwu 
* @date         : 2018年12月12日 下午10:27:54 
* @Description  : 通用controller
*/
@Api(value = "通用controller",description = "通用controller")
@RestController
@RequestMapping("/common/v1")
public class CommonController {

	@Autowired
	private TImageConfigMapper tImageConfigMapper;
	
    @LogInfo(log = "获取图片")
    @PostMapping("/getImage")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "图片类型", required = false, dataType = "String", paramType = "query"),
    })
    public ResponseEntity  getImage(@RequestParam(value = "type") String type){
		TImageConfigExample example = new TImageConfigExample();
		example.createCriteria().andImgTypeEqualTo(type);
		List<TImageConfig> result= tImageConfigMapper.selectByExample(example);
		TImageConfig image = result.get(0);
        return ResponseEntity.ok(image.getImgUrl());
    }
}
